package com.cloudsigns.factorymanager2.project.activity;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.baidu.mapapi.map.BaiduMap;
import com.baidu.mapapi.map.BitmapDescriptor;
import com.baidu.mapapi.map.BitmapDescriptorFactory;
import com.baidu.mapapi.map.MapStatus;
import com.baidu.mapapi.map.MapStatusUpdateFactory;
import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.map.Marker;
import com.baidu.mapapi.map.MarkerOptions;
import com.baidu.mapapi.map.OverlayOptions;
import com.baidu.mapapi.model.LatLng;
import com.cloudsigns.factorymanager2.R;
import com.cloudsigns.factorymanager2.cusenum.CommonEnum;
import com.cloudsigns.factorymanager2.engineering.IView.InEngineeringOrderListForMapView;
import com.cloudsigns.factorymanager2.engineering.activity.EngineeringInstallFeedBackForWaitStateActivity;
import com.cloudsigns.factorymanager2.engineering.activity.EngineeringInstallStatusTableForManagerActivity;
import com.cloudsigns.factorymanager2.engineering.activity.EngineeringMainForManagerActivity;
import com.cloudsigns.factorymanager2.engineering.activity.EngineeringMainForSuperActivity;
import com.cloudsigns.factorymanager2.engineering.activity.PatrolStatusTableForManagerActivity;
import com.cloudsigns.factorymanager2.engineering.activity.PublicationStatusTableForManagerActivity2;
import com.cloudsigns.factorymanager2.engineering.bean.OrderParentBean;
import com.cloudsigns.factorymanager2.engineering.customview.BottomDialog;
import com.cloudsigns.factorymanager2.engineering.presenter.EngineeringOrderListForMapPresenter;
import com.cloudsigns.factorymanager2.project.customview.DropDownPoupWindow;
import com.cloudsigns.factorymanager2.project.utils.ConstantUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * 工程管理地图页
 * Created by tony on 2018/8/4.
 */

public class ProjectMapActivity extends Activity implements View.OnClickListener, BottomDialog.OnBottomDialogClick, InEngineeringOrderListForMapView {
    private View ll_op_one, ll_op_two, ll_op_three, ll_op_four;
    private ImageView img_op_one, img_op_two, img_op_three, img_op_four;
    private RelativeLayout rl_back,rl_head;
    private TextView tv_title;
    private MapView bmapView;
    private BaiduMap mBaiduMap;
    private final String TAG = ProjectMapActivity.class.getSimpleName();
    private DropDownPoupWindow popupWindow;
    /*标题栏四个按钮类型*/
    /*功能*/
    public static final int BTN_MODULE = 0;
    /*表格*/
    public static final int BTN_TABLE = 1;
    /*状态*/
    public static final int BTN_STATU = 2;
    /*项目选择*/
    public static final int BTN_SELECT = 3;

    private int currentBtn = -1;
    /*工程管理*/
    public static final int MODULE_ENGINEERING_MANAGEMENT = 0;
    /*轨迹*/
    public static final int MODULE_TRACK = 1;
    /*智能控制*/
    public static final int MODULE_INTELLIGENT = 2;
    /*供需*/
    public static final int MODULE_GONGXU = 3;
    /*标题栏 第一个按钮 当前选中的功能*/
    public int currentModuleType = MODULE_ENGINEERING_MANAGEMENT;

    private EngineeringOrderListForMapPresenter engineeringOrderListForMapPresenter;
    private List<OrderParentBean> engineeringOrderList;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏
        // 沉浸式状态栏
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                    );
            window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN

                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(Color.TRANSPARENT);

        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        }


        setContentView(R.layout.layout_engineeringmanage_map);

        engineeringOrderListForMapPresenter = new EngineeringOrderListForMapPresenter(this);
        init();

        engineeringOrderListForMapPresenter.getEngineeringOrderList();
    }

    private void init() {
        rl_back = findViewById(R.id.rl_back);
        tv_title = findViewById(R.id.tv_title);
        rl_head=findViewById(R.id.rl_head);
        ll_op_one = findViewById(R.id.ll_op_one);
        ll_op_two = findViewById(R.id.ll_op_two);
        ll_op_two = findViewById(R.id.ll_op_two);
        ll_op_three = findViewById(R.id.ll_op_three);
        ll_op_four = findViewById(R.id.ll_op_four);
        img_op_one = findViewById(R.id.img_op_one);
        img_op_two = findViewById(R.id.img_op_two);
        img_op_three = findViewById(R.id.img_op_three);
        img_op_four = findViewById(R.id.img_op_four);

        tv_title.setText(getResources().getText(R.string.engineering_management));

//        img_op_one.setBackgroundResource(R.mipmap.dituqiehuan);
//        img_op_two.setBackgroundResource(R.mipmap.zhuangtaibiao);
//        img_op_three.setBackgroundResource(R.mipmap.sebiao);
//        img_op_four.setBackgroundResource(R.mipmap.qiehuan);


        img_op_one.setBackgroundResource(R.mipmap.title_icon_menu);
        img_op_two.setBackgroundResource(R.mipmap.icon_hand);
        img_op_three.setBackgroundResource(R.mipmap.icon_produced);
        img_op_four.setBackgroundResource(R.mipmap.icon_patrol);


        ll_op_one.setVisibility(View.VISIBLE);
        ll_op_two.setVisibility(View.GONE);
        ll_op_three.setVisibility(View.VISIBLE);
        ll_op_four.setVisibility(View.VISIBLE);
        rl_back.setVisibility(View.VISIBLE);
        rl_head.setVisibility(View.GONE);

        ll_op_one.setOnClickListener(this);
        ll_op_two.setOnClickListener(this);
        ll_op_three.setOnClickListener(this);
        ll_op_four.setOnClickListener(this);
        rl_back.setOnClickListener(this);

        //获取地图控件引用
        bmapView = findViewById(R.id.bmapView);
        //不显示缩放控件
        bmapView.showZoomControls(false);
        /*获取地图对象*/
        mBaiduMap = bmapView.getMap();

        resetMapView();
        mBaiduMap.setOnMarkerClickListener(onMarkerClickListener);
    }


    /**
     * 功能1
     *
     * @param anchor
     */
    private void showModulePopupWindow(View anchor) {
        if (null != popupWindow)
            popupWindow.dismiss();

        popupWindow = new DropDownPoupWindow(this, TAG, BTN_MODULE, R.layout.popwindow_map_for_manager_module, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        backgroundAlpha(0.4f);
        popupWindow.setOnClickListener(this);
        popupWindow.setCusOnDismissListener(new PopupWindow.OnDismissListener() {

            @Override
            public void onDismiss() {
                backgroundAlpha(1f);

            }
        });
        popupWindow.showPopupWindow(anchor, anchor.getLayoutParams().width / 2, 5);
    }

    /**
     * 功能2
     *
     * @param anchor
     */
    private void showEngineeringPopupWindwo(View anchor) {
        if (null != popupWindow)
            popupWindow.dismiss();

        popupWindow = new DropDownPoupWindow(this, TAG, BTN_TABLE, R.layout.popwindow_map_for_manager_engineering, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        backgroundAlpha(0.4f);
        popupWindow.setOnClickListener(this);
        popupWindow.setCusOnDismissListener(new PopupWindow.OnDismissListener() {

            @Override
            public void onDismiss() {
                backgroundAlpha(1f);

            }
        });
        popupWindow.showPopupWindow(anchor, anchor.getLayoutParams().width / 2, 5);
    }

    /**
     * 功能3
     *
     * @param anchor
     */
    private void showStatusPopupWindow(View anchor) {
        if (null != popupWindow)
            popupWindow.dismiss();

        popupWindow = new DropDownPoupWindow(this, TAG, BTN_STATU, R.layout.popwindow_map_for_manager_status, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        backgroundAlpha(0.4f);
        popupWindow.setOnClickListener(this);
        popupWindow.setCusOnDismissListener(new PopupWindow.OnDismissListener() {

            @Override
            public void onDismiss() {
                backgroundAlpha(1f);

            }
        });
        popupWindow.showPopupWindow(anchor, anchor.getLayoutParams().width / 2, 5);
    }

    /**
     * 功能4
     *
     * @param anchor
     */
    private void showSelectPopupWindwo(View anchor) {
        if (null != popupWindow)
            popupWindow.dismiss();


        popupWindow = new DropDownPoupWindow(this, TAG, BTN_SELECT, R.layout.popwindow_map_for_manager_selectproject, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        backgroundAlpha(0.4f);
        popupWindow.setOnClickListener(this);
        popupWindow.setCusOnDismissListener(new PopupWindow.OnDismissListener() {

            @Override
            public void onDismiss() {
                backgroundAlpha(1f);

            }
        });
        popupWindow.showPopupWindow(anchor, anchor.getLayoutParams().width / 2, 5);
    }


    /**
     * 设置添加屏幕的背景透明�?
     *
     * @param bgAlpha
     */
    private void backgroundAlpha(float bgAlpha) {
        WindowManager.LayoutParams lp = getWindow().getAttributes();
        lp.alpha = bgAlpha;
        getWindow().setAttributes(lp);
    }


    /*设置地图默认显示坐标点和缩放级别*/
    private void resetMapView() {
        int zoom = 5;
        double latDefault = 34.0;
        double lngDefault = 108.0;

        try {
            if (mBaiduMap != null) {
                mBaiduMap.setMapStatus(MapStatusUpdateFactory.newMapStatus(new MapStatus.Builder().target(new LatLng(latDefault, lngDefault)).zoom(zoom).build()));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    /*选择一个工程后设置以该项目为中心的地图显示*/
    public void selectEngineering(double lat, double lng) {

        LatLng latLng = new LatLng(lat, lng);
        if (mBaiduMap != null) {
            mBaiduMap.setMapStatus(MapStatusUpdateFactory.newMapStatus(new MapStatus.Builder().zoom(17).target(latLng).build()));
        }
    }

    BaiduMap.OnMarkerClickListener onMarkerClickListener = new BaiduMap.OnMarkerClickListener() {
        @Override
        public boolean onMarkerClick(final Marker marker) {
            Bundle bundle = marker.getExtraInfo();
            if (null != bundle) {
                if (currentModuleType == EngineeringMainForManagerActivity.MODULE_ENGINEERING_MANAGEMENT) {
                    OrderParentBean orderParentBean = (OrderParentBean) bundle.getSerializable(ConstantUtil.KEY_1);

                    selectEngineering(orderParentBean.getLat(), orderParentBean.getLon());


                    BottomDialog dialog = new BottomDialog(ProjectMapActivity.this, orderParentBean);
                    dialog.setBottomDialogClick(ProjectMapActivity.this);
                    dialog.show();

                } else if (currentModuleType == EngineeringMainForManagerActivity.MODULE_TRACK) {


                } else if (currentModuleType == EngineeringMainForManagerActivity.MODULE_INTELLIGENT) {

                } else if (currentModuleType == EngineeringMainForManagerActivity.MODULE_GONGXU) {

                }


            }

            return true;
        }
    };

    @Override
    public void onDialogClick(OrderParentBean orderParentBean) {
        if (null != orderParentBean) {
            CommonEnum.FeedBackState feedBackState = orderParentBean.getFeedBackState();
            Intent mIntent;
            if (CommonEnum.FeedBackState.EXCEPTION == feedBackState) {
                mIntent = new Intent(ProjectMapActivity.this, EngineeringInstallFeedBackForWaitStateActivity.class);
//                        mIntent = new Intent(getActivity(), EngineeringFeedBackForExceptionStateActivity.class);
                mIntent.putExtra(ConstantUtil.KEY_1, orderParentBean);
                mIntent.putExtra(ConstantUtil.KEY_2, TAG);
                startActivity(mIntent);

            } else if (CommonEnum.FeedBackState.WAIT_CONFIRM == feedBackState) {
                mIntent = new Intent(ProjectMapActivity.this, EngineeringInstallFeedBackForWaitStateActivity.class)
                ;
                mIntent.putExtra(ConstantUtil.KEY_1, orderParentBean);
                mIntent.putExtra(ConstantUtil.KEY_2, TAG);
                startActivityForResult(mIntent, ConstantUtil.START_ACTIVITY_KEY_1);

            } else if (CommonEnum.FeedBackState.WORKING == feedBackState) {
                mIntent = new Intent(ProjectMapActivity.this, EngineeringInstallFeedBackForWaitStateActivity.class);
//                        mIntent = new Intent(getActivity(), EngineeringFeedBackForWorkingStateActivity.class);
                mIntent.putExtra(ConstantUtil.KEY_1, orderParentBean);
                startActivity(mIntent);

            } else if (CommonEnum.FeedBackState.COMPLETE == feedBackState) {
                mIntent = new Intent(ProjectMapActivity.this, EngineeringInstallFeedBackForWaitStateActivity.class);
//                        mIntent = new Intent(getActivity(), EngineeringFeedBackForCompletionStateActivity.class);
                mIntent.putExtra(ConstantUtil.KEY_1, orderParentBean);
                mIntent.putExtra(ConstantUtil.KEY_2, TAG);
                startActivity(mIntent);


            } else if (CommonEnum.FeedBackState.OUT_OF_PLAN == feedBackState) {
                mIntent = new Intent(ProjectMapActivity.this, EngineeringInstallFeedBackForWaitStateActivity.class);
                mIntent.putExtra(ConstantUtil.KEY_1, orderParentBean);
                mIntent.putExtra(ConstantUtil.KEY_2, TAG);
                startActivityForResult(mIntent, ConstantUtil.START_ACTIVITY_KEY_1);

            } else if (CommonEnum.FeedBackState.NO_FEEDBACK == feedBackState) {
                mIntent = new Intent(ProjectMapActivity.this, EngineeringInstallFeedBackForWaitStateActivity.class);
                mIntent.putExtra(ConstantUtil.KEY_1, orderParentBean);
                mIntent.putExtra(ConstantUtil.KEY_2, TAG);
                startActivityForResult(mIntent, ConstantUtil.START_ACTIVITY_KEY_1);

            } else if (CommonEnum.FeedBackState.PAUSE == feedBackState) {
                mIntent = new Intent(ProjectMapActivity.this, EngineeringInstallFeedBackForWaitStateActivity.class);
//                        mIntent = new Intent(getActivity(), EngineeringFeedBackForPauseStateActivity.class);
                mIntent.putExtra(ConstantUtil.KEY_1, orderParentBean);
                mIntent.putExtra(ConstantUtil.KEY_2, TAG);
                startActivity(mIntent);
            } else if (CommonEnum.FeedBackState.CREATE == feedBackState) {
                mIntent = new Intent(ProjectMapActivity.this, EngineeringInstallFeedBackForWaitStateActivity.class);
//                        mIntent = new Intent(getActivity(), EngineeringFeedBackForPauseStateActivity.class);
                mIntent.putExtra(ConstantUtil.KEY_1, orderParentBean);
                mIntent.putExtra(ConstantUtil.KEY_2, TAG);
                startActivity(mIntent);
            }
//            Intent mIntent = new Intent(getActivity(), EngineeringInstallOrderForSuperActivity.class);
//            mIntent.putExtra(ConstantUtil.KEY_1, orderParentBean);
//            startActivity(mIntent);
        }

    }

    public void getOrderList(int engineeringType) {
        resetMapView();

        currentModuleType = engineeringType;
        mBaiduMap.clear();

        if (currentModuleType == EngineeringMainForManagerActivity.MODULE_ENGINEERING_MANAGEMENT) { //工程管理
            engineeringOrderListForMapPresenter.getEngineeringOrderList();

        } else if (currentModuleType == EngineeringMainForManagerActivity.MODULE_TRACK) { //轨迹

        } else if (currentModuleType == EngineeringMainForManagerActivity.MODULE_INTELLIGENT) { //智能控制

        } else if (currentModuleType == EngineeringMainForManagerActivity.MODULE_GONGXU) { //供需

        }

    }

    private void updataMap() {

        if (currentModuleType == EngineeringMainForManagerActivity.MODULE_ENGINEERING_MANAGEMENT) { //工程管理
            if (null != engineeringOrderList) {
                addMarker(engineeringOrderList);
            }

        } else if (currentModuleType == EngineeringMainForManagerActivity.MODULE_TRACK) { //轨迹

        } else if (currentModuleType == EngineeringMainForManagerActivity.MODULE_INTELLIGENT) { //智能控制

        } else if (currentModuleType == EngineeringMainForManagerActivity.MODULE_GONGXU) { //供需

        }


    }

    /*往地图添加一个点*/

    private void addMarker(List<OrderParentBean> orderParentBeanList) {

        //创建OverlayOptions的集合

        List<OverlayOptions> options = new ArrayList<OverlayOptions>();
        //构建Marker图标
        BitmapDescriptor bitmap_exception = null;
        BitmapDescriptor bitmap_wait_confirm = null;
        BitmapDescriptor bitmap_working = null;
        BitmapDescriptor bitmap_complete = null;
        BitmapDescriptor bitmap_out_plan = null;
        BitmapDescriptor bitmap_no_feedback = null;
        BitmapDescriptor bitmap_pause = null;
        BitmapDescriptor bitmap_create = null;

        LatLng point;
        Bundle bundle = null;
        String title = "";
        BitmapDescriptor bitmap = null;

        for (int i = 0; i < orderParentBeanList.size(); i++) {
            bitmap = null;

            OrderParentBean orderParentBean = orderParentBeanList.get(i);

            bundle = new Bundle();
            bundle.putSerializable(ConstantUtil.KEY_1, orderParentBean);

            CommonEnum.EngineeringORderCategory oRderCategory = orderParentBean.getCategory();
            if (null != oRderCategory) {
                if (oRderCategory == CommonEnum.EngineeringORderCategory.INSTALL) {
                    title = "工程安装";
                } else if (oRderCategory == CommonEnum.EngineeringORderCategory.BATCH_INSTALL) {
                    title = "批量工程";
                } else if (oRderCategory == CommonEnum.EngineeringORderCategory.CONSTRUCT) {
                    title = "施工";
                } else if (oRderCategory == CommonEnum.EngineeringORderCategory.MAINTAIN) {
                    title = "维修";
                } else if (oRderCategory == CommonEnum.EngineeringORderCategory.PUBLICATION) {
                    title = "上刊";
                    ;
                } else if (oRderCategory == CommonEnum.EngineeringORderCategory.PATROL) {
                    title = "巡查";
                } else if (oRderCategory == CommonEnum.EngineeringORderCategory.PATROL) {
                    title = "现场勘察";
                }
            }

//            //设置坐标点
//            int j = i % 16;
//            point = new LatLng(latList.get(j), lonList.get(j));
            point = new LatLng(orderParentBean.getLat(), orderParentBean.getLon());


            OverlayOptions option = null;

            CommonEnum.FeedBackState feedBackState = orderParentBean.getFeedBackState();
            if (CommonEnum.FeedBackState.EXCEPTION == feedBackState) {
                if (null == bitmap_exception) {
                    Bitmap tmpBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.icon_map_2);

                    //构建Marker图标
                    bitmap_exception = BitmapDescriptorFactory
                            .fromBitmap(tmpBitmap);
                }

                bitmap = bitmap_exception;

//                //在地图上添加Marker，并显示
//                mBaiduMap.addOverlay(option);


            } else if (CommonEnum.FeedBackState.WAIT_CONFIRM == feedBackState) {
                if (null == bitmap_wait_confirm) {
                    Bitmap tmpBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.icon_map_1);
                    //构建Marker图标
                    bitmap_wait_confirm = BitmapDescriptorFactory
                            .fromBitmap(tmpBitmap);
                }

                bitmap = bitmap_wait_confirm;

//                //在地图上添加Marker，并显示
//                mBaiduMap.addOverlay(option);
            } else if (CommonEnum.FeedBackState.WORKING == feedBackState) {
                if (null == bitmap_working) {
                    Bitmap tmpBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.icon_map_3);
                    //构建Marker图标
                    bitmap_working = BitmapDescriptorFactory
                            .fromBitmap(tmpBitmap);
                }
                bitmap = bitmap_working;

//                //在地图上添加Marker，并显示
//                mBaiduMap.addOverlay(option);
            } else if (CommonEnum.FeedBackState.COMPLETE == feedBackState) {
                if (null == bitmap_complete) {
                    Bitmap tmpBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.icon_map_7);
                    //构建Marker图标
                    bitmap_complete = BitmapDescriptorFactory
                            .fromBitmap(tmpBitmap);
                }
                bitmap = bitmap_complete;

//                //在地图上添加Marker，并显示
//                mBaiduMap.addOverlay(option);
            } else if (CommonEnum.FeedBackState.OUT_OF_PLAN == feedBackState) {
                if (null == bitmap_out_plan) {
                    Bitmap tmpBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.icon_map_4);
                    //构建Marker图标
                    bitmap_out_plan = BitmapDescriptorFactory
                            .fromBitmap(tmpBitmap);
                }
                bitmap = bitmap_out_plan;

//                //在地图上添加Marker，并显示
//                mBaiduMap.addOverlay(option);
            } else if (CommonEnum.FeedBackState.NO_FEEDBACK == feedBackState) {
                if (null == bitmap_no_feedback) {
                    Bitmap tmpBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.icon_map_5);
                    //构建Marker图标
                    bitmap_no_feedback = BitmapDescriptorFactory
                            .fromBitmap(tmpBitmap);
                }
                bitmap = bitmap_no_feedback;

//                //在地图上添加Marker，并显示
//                mBaiduMap.addOverlay(option);
            } else if (CommonEnum.FeedBackState.PAUSE == feedBackState) {
                if (null == bitmap_pause) {
                    Bitmap tmpBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.icon_map_6);
                    //构建Marker图标
                    bitmap_pause = BitmapDescriptorFactory
                            .fromBitmap(tmpBitmap);
                }
                bitmap = bitmap_pause;

//                //在地图上添加Marker，并显示
//                mBaiduMap.addOverlay(option);
            } else if (CommonEnum.FeedBackState.CREATE == feedBackState) {
                if (null == bitmap_create) {
                    Bitmap tmpBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.icon_map_8);
                    //构建Marker图标
                    bitmap_create = BitmapDescriptorFactory
                            .fromBitmap(tmpBitmap);
                }
                bitmap = bitmap_create;
            }


            //创建OverlayOptions属性
            if (null != bitmap)
                option = new MarkerOptions()
                        .position(point)
                        .title(title)
                        .extraInfo(bundle)
                        .icon(bitmap);


            //将OverlayOptions添加到list
            if (null != option)
                options.add(option);


        }


        //在地图上批量添加
        mBaiduMap.addOverlays(options);

    }


    private void showStatusPopupWindwo(View anchor) {
        if (null != popupWindow)
            popupWindow.dismiss();


        switch (currentModuleType) {

            case MODULE_ENGINEERING_MANAGEMENT:
                popupWindow = new DropDownPoupWindow(ProjectMapActivity.this, "", -1, R.layout.popwindow_map_for_super_engineering_status, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                popupWindow.setOnClickListener(this);
                popupWindow.setCusOnDismissListener(new PopupWindow.OnDismissListener() {

                    @Override
                    public void onDismiss() {


                    }
                });
                popupWindow.showPopupWindow(anchor, anchor.getLayoutParams().width / 2, 5);
                break;
            case MODULE_TRACK:

                break;
            case MODULE_INTELLIGENT:

                break;
            case MODULE_GONGXU:

                break;
        }

    }


    @Override
    public void onClick(View view) {
        Intent mIntent;
        switch (view.getId()) {
            case R.id.ll_op_one:
                showModulePopupWindow(view);
                break;
            case R.id.ll_op_two:
                showEngineeringPopupWindwo(view);
                break;
            case R.id.ll_op_three:
                showStatusPopupWindow(view);
                break;
            case R.id.ll_op_four:
                showSelectPopupWindwo(view);
                break;
            case R.id.rl_back:
                finish();
                break;
            // 工程管理
            case R.id.ll_engineering_management:
                getOrderList(MODULE_ENGINEERING_MANAGEMENT);
                showStatusPopupWindwo(ll_op_two);
                break;
            // 轨迹
            case R.id.ll_track:
                break;
            // 智能控制
            case R.id.ll_intelligent_control:
                break;
            // 业绩
            case R.id.ll_achievement:
                break;
            // 供需中心
            case R.id.ll_gongxu:
                break;
                // 工程安装
            case R.id.ll_engineering_installation:
                mIntent = new Intent(ProjectMapActivity.this, EngineeringInstallStatusTableForManagerActivity.class);
                startActivity(mIntent);
                break;
                // 工程施工
            case R.id.ll_engineering_construct:
                mIntent = new Intent(ProjectMapActivity.this, ProductionScheduleActivity.class);
                startActivity(mIntent);
                break;
                // 批量安装
            case R.id.ll_batch_engineering:
                mIntent = new Intent(ProjectMapActivity.this, EngineeringInstallationScheduleTableActivity.class);
                startActivity(mIntent);
                break;
            // 上刊
            case R.id.ll_publication:
                mIntent = new Intent(ProjectMapActivity.this, PublicationStatusTableForManagerActivity2.class);
                startActivity(mIntent);
                break;
                // 维修
            case R.id.ll_maintenance:
                mIntent = new Intent(ProjectMapActivity.this, ProductStatusTableActivity.class);
                startActivity(mIntent);
                break;
               // 勘察
            case R.id.ll_patrol:
                mIntent = new Intent(ProjectMapActivity.this, PatrolStatusTableForManagerActivity.class);
                startActivity(mIntent);
                break;
        }
    }


    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (null != data) {
            switch (requestCode) {
                case ConstantUtil.START_ACTIVITY_KEY_1:
                    getOrderList(currentModuleType);
                    break;

            }
        }

        super.onActivityResult(requestCode, resultCode, data);
    }

    @Override
    protected void onDestroy() {
        if (null != popupWindow) {
            popupWindow.dismiss();
            popupWindow = null;
        }
        super.onDestroy();

    }

    @Override
    public void getEngineeringOrderListForMapFailed(String desc) {

    }

    @Override
    public void getEngineeringOrderListForMapSuccessed(List<OrderParentBean> allOrderList, List<OrderParentBean> maintenaceOrderList, List<OrderParentBean> engineeringManagerorderList) {
        this.engineeringOrderList = allOrderList;
        updataMap();
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }
}
